Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skrifa] FontRef instead of TableProvider #1079

Merged
merged 6 commits into from
Aug 15, 2024
Merged

[skrifa] FontRef instead of TableProvider #1079

merged 6 commits into from
Aug 15, 2024

Conversation

dfrg
Copy link
Member

@dfrg dfrg commented Aug 10, 2024

Per IM, changes skrifa to use FontRef directly rather than TableProvider.

Extracts some shared functionality into a BaseOutlines type for outlines in preparation for more autohinting work but no real functional changes.

Per IM, changes skrifa to use `FontRef` directly rather than `TableProvider`.

Extracts some shared functionality into a `BaseScaler` type for outlines in preparation for more autohinting work but no real functional changes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding Empty seems like it might have been a nice standalone, very small and easy to review

impl<'a> BaseOutlines<'a> {
pub fn new(font: &FontRef<'a>) -> Option<Self> {
let hmtx = font.hmtx().ok()?;
let hvar = font.hvar().ok();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps worth a comment that we need hmtx, it's ok if there is no hvar

when the types don't popup it's very easy to miss that only one has a ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if let Some(hvar) = &self.hvar {
advance += hvar
.advance_width_delta(gid, coords)
// FreeType truncates metric deltas...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bonus points for reference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is actually stale so I removed it. We added rounding to the IVS itself in an earlier patch to match FT.

lsb
}

pub fn cvt(&self) -> &[BigEndian<i16>] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both lsb and cvt merit a comment clarifying what that even is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


/// Common functionality for glyf, cff and autohinting scalers.
#[derive(Clone)]
pub(crate) struct BaseOutlines<'a> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see cff or glyf structs holding base: BaseOutlines I'm left unclear what that does. I definitely wouldn't have anticipated the FontRef hides here.

Base is strongly associated with something you derive from for many of us and doesn't really conveying the common bits concept.

To ask the obvious, why not write a trait and implement it for FontRef? - cff and glyf holding font: FontRef and calling e.g. font.lsb would read more clearly to me. The main service this seems to serve is to avoid calling font.hmtx but if that's too slow ... maybe we could make it not be?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf measurements suggest that looking up the tables on demand roughly doubles the cost of metrics retrieval. This may be acceptable for static text, but the animated variable case is one we like to highlight so wasting cycles for the sake of purity seems ill advised.

I renamed base -> common and BaseOutlines to OutlinesCommon for now. I agree this isn't ideal but I'd like to make progress on autohinting so I filed #1085 to revisit this in the future.

Copy link
Collaborator

@rsheeter rsheeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM subject to BaseOutlines concerns being addressed

@rsheeter rsheeter added this to the Skrifa for Chrome milestone Aug 12, 2024
- rename base -> common and BaseOutlines -> OutlinesCommon
- add some doc comments
@dfrg dfrg merged commit a80a9f4 into main Aug 15, 2024
10 checks passed
@dfrg dfrg deleted the skrifa-font-ref branch August 15, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants